/**
  ******************************************************************************
  * File Name          : dclcdpro.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "bsp.h"
#include "tskcfg.h"
#include "dclcd.h"
#include "gui_asclib.h"
#include "gv.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>

#define DCLCD_FRAME_HEADER    0xEEu;

//#define DCLCD_SEND_INTERFACE_DIRECT

static DcLcd_SendStru dclcd_cmd;

#ifdef DCLCD_SEND_INTERFACE_DIRECT
  #define dclcd_send_interface(x)       dclcd_send_buf(x.buf, x.cnt)
#else
  #define dclcd_send_interface(x)       xQueueSend(dclcd_send_qhd, &x, 0)
#endif

static void dc_cb_recv_datetime(const uint8_t *buf, uint16_t len);

//static const DcLcd_SendStru dclcd_cmd_get_sid = 
//{
//  .needreply = 0,
//  .reptimeout = 0,
//  .cnt = 7,
//  .buf = {0xEEu, 0xB1u, 0x01u, 0xFFu, 0xFCu, 0xFFu, 0xFFu},
//  .replycb = NULL,
//};

const DcLcd_SendStru dclcd_cmd_get_datetime = 
{
  .needreply = 1,
  .reptimeout = 200,
  .cnt = 6,
  .buf = {0xEEu, 0x82u, 0xFF, 0xFCu, 0xFFu, 0xFFu},
  .replycb = dc_cb_recv_datetime,
};

void dc_set_datetime(uint8_t bcd_year, uint8_t bcd_month, uint8_t bcd_day, uint8_t bcd_hour, uint8_t bcd_minute, uint8_t bcd_second)
{
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;

  dclcd_cmd.buf[1] = 0x81u;

  dclcd_cmd.buf[2] = bcd_second;
  dclcd_cmd.buf[3] = bcd_minute;
  dclcd_cmd.buf[4] = bcd_hour;

  dclcd_cmd.buf[5] = bcd_day;
  dclcd_cmd.buf[6] = 0x00;
  dclcd_cmd.buf[7] = bcd_month;
  dclcd_cmd.buf[8] = bcd_year;
  
  dclcd_cmd.buf[9]  = 0xFFu;
  dclcd_cmd.buf[10] = 0xFCu;
  dclcd_cmd.buf[11] = 0xFFu;
  dclcd_cmd.buf[12] = 0xFFu;
  
  dclcd_cmd.cnt = 13;

  dclcd_send_interface(dclcd_cmd);
}

static void dc_cb_recv_datetime(const uint8_t *buf, uint16_t len)
{
  Sys_DataTimeStru adj;

  if(len != 13)
  {
    return;
  }

  if((buf[0] != 0xEEu) || (buf[1] != 0xF7))
  {
    return;
  }

  if((buf[9] != 0xFFu) || (buf[10] != 0xFCu) || (buf[11] != 0xFFu) || (buf[12] != 0xFFu))
  {
    return;
  }

  /* year */
  adj.year = BCD2BIN(buf[2]);
  if(adj.year > 99u)
  {
    return;
  }

  /* month */
  adj.month = BCD2BIN(buf[3]);
  if((adj.month < 1u) || (adj.month > 12u))
  {
    return;
  }
  
  /* day */
  adj.day = BCD2BIN(buf[5]);
  if((adj.day < 1u) || (adj.day > 31u))
  {
    return;
  }

  /* hour */
  adj.hour = BCD2BIN(buf[6]);
  if(adj.hour > 23u)
  {
    return;
  }

  /* minute */
  adj.minute = BCD2BIN(buf[7]);
  if(adj.minute > 59u)
  {
    return;
  }

  /* second */
  adj.second = BCD2BIN(buf[8]);
  if(adj.second > 59u)
  {
    return;
  }

  sys_set_datatime(&adj);
}

void dc_cmd_change_screen(uint16_t sid)
{
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x00u;
  
  dclcd_cmd.buf[3] = (uint8_t)(sid >> 8);
  dclcd_cmd.buf[4] = (uint8_t)sid;
  
  dclcd_cmd.buf[5] = 0xFFu;
  dclcd_cmd.buf[6] = 0xFCu;
  dclcd_cmd.buf[7] = 0xFFu;
  dclcd_cmd.buf[8] = 0xFFu;
  
  dclcd_cmd.cnt = 9;
  
  dclcd_send_interface(dclcd_cmd);
}

void dc_cmd_buzzer(uint8_t t10ms)
{
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0x61u;
  dclcd_cmd.buf[2] = t10ms;
  
  dclcd_cmd.buf[3] = 0xFFu;
  dclcd_cmd.buf[4] = 0xFCu;
  dclcd_cmd.buf[5] = 0xFFu;
  dclcd_cmd.buf[6] = 0xFFu;
  
  dclcd_cmd.cnt = 7;
  
  dclcd_send_interface(dclcd_cmd);
}

void dc_cmd_textfocus(uint16_t sid, uint16_t cid, uint8_t txf)
{
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;

  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x02u;

  dclcd_cmd.buf[3] = (uint8_t)(sid >> 8);
  dclcd_cmd.buf[4] = (uint8_t)sid;

  dclcd_cmd.buf[5] = (uint8_t)(cid >> 8);
  dclcd_cmd.buf[6] = (uint8_t)cid;

  if(txf != 0)
  {
    dclcd_cmd.buf[7] = 1;
  }
  else
  {
    dclcd_cmd.buf[7] = 0;
  }

  dclcd_cmd.buf[8] = 0xFFu;
  dclcd_cmd.buf[9] = 0xFCu;
  dclcd_cmd.buf[10] = 0xFFu;
  dclcd_cmd.buf[11] = 0xFFu;

  dclcd_cmd.cnt = 12;

  dclcd_send_interface(dclcd_cmd);
}

void dc_cmd_fixcursor(uint8_t off0on1)
{
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;

  dclcd_cmd.buf[1] = 0x21u;

  if(off0on1 != 0)
  {
    dclcd_cmd.buf[2] = 0x01u;
  }
  else
  {
    dclcd_cmd.buf[2] = 0x00u;
  }

  dclcd_cmd.buf[3] = 0x01u;
  dclcd_cmd.buf[4] = 0xA4u;

  dclcd_cmd.buf[5] = 0x01u;
  dclcd_cmd.buf[6] = 0x0cu;
  
  dclcd_cmd.buf[7] = 5;

  dclcd_cmd.buf[8] = 53;

  dclcd_cmd.buf[9]  = 0xFFu;
  dclcd_cmd.buf[10] = 0xFCu;
  dclcd_cmd.buf[11] = 0xFFu;
  dclcd_cmd.buf[12] = 0xFFu;

  dclcd_cmd.cnt = 13;

  dclcd_send_interface(dclcd_cmd);
}

void dc_cmd_textflash(uint16_t sid, uint16_t cid, uint16_t cycle)
{
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;

  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x15u;

  dclcd_cmd.buf[3] = (uint8_t)(sid >> 8);
  dclcd_cmd.buf[4] = (uint8_t)sid;

  dclcd_cmd.buf[5] = (uint8_t)(cid >> 8);
  dclcd_cmd.buf[6] = (uint8_t)cid;
  
  dclcd_cmd.buf[7] = (uint8_t)(cycle >> 8);
  dclcd_cmd.buf[8] = (uint8_t)cycle;

  dclcd_cmd.buf[9]  = 0xFFu;
  dclcd_cmd.buf[10] = 0xFCu;
  dclcd_cmd.buf[11] = 0xFFu;
  dclcd_cmd.buf[12] = 0xFFu;

  dclcd_cmd.cnt = 13;

  dclcd_send_interface(dclcd_cmd);
}

void dc_cmd_set_str(uint16_t sid, uint16_t cid, const char * str)
{
  uint16_t i;
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x10u;
  
  dclcd_cmd.buf[3] = (uint8_t)(sid >> 8);
  dclcd_cmd.buf[4] = (uint8_t)sid;
  
  dclcd_cmd.buf[5] = (uint8_t)(cid >> 8);
  dclcd_cmd.buf[6] = (uint8_t)cid;
  
  for(i=0; i<(DCLCD_FRAME_MAXLEN-11); i++)
  {
    if(str[i] == '\0')
    {
      break;
    }
    
    dclcd_cmd.buf[i+7] = str[i];
  }
  
  dclcd_cmd.buf[i+7] = 0xFFu;
  dclcd_cmd.buf[i+8] = 0xFCu;
  dclcd_cmd.buf[i+9] = 0xFFu;
  dclcd_cmd.buf[i+10] = 0xFFu;
  
  dclcd_cmd.cnt = i+11;
  
  dclcd_send_interface(dclcd_cmd);
}

void dc_cmd_set_format(uint16_t sid, uint16_t cid, const char *format, ...)
{
  uint8_t i;
  va_list args;
  
  if(format == NULL)
  {
    return;
  }
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x10u;
  
  dclcd_cmd.buf[3] = (uint8_t)(sid >> 8);
  dclcd_cmd.buf[4] = (uint8_t)sid;
  
  dclcd_cmd.buf[5] = (uint8_t)(cid >> 8);
  dclcd_cmd.buf[6] = (uint8_t)cid;
  
  va_start(args, format);
  i = vsnprintf((char *)(dclcd_cmd.buf+7), (DCLCD_FRAME_MAXLEN-11), format, args);
  va_end(args);
  
  dclcd_cmd.buf[i+7] = 0xFFu;
  dclcd_cmd.buf[i+8] = 0xFCu;
  dclcd_cmd.buf[i+9] = 0xFFu;
  dclcd_cmd.buf[i+10] = 0xFFu;
  
  dclcd_cmd.cnt = i+11;
  
  dclcd_send_interface(dclcd_cmd);
}

/**
  * @brief  显示或者隐藏某个项目
  * @param  sid 页面编号
  * @param  cid 控件编号
  * @param  show0hide1 0:显示,1:隐藏
  * @retval None
  */
void dc_comp_showhide(uint16_t sid, uint16_t cid, uint8_t show0hide1)
{
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x03u;
  
  dclcd_cmd.buf[3] = (uint8_t)(sid >> 8);
  dclcd_cmd.buf[4] = (uint8_t)sid;
  
  dclcd_cmd.buf[5] = (uint8_t)(cid >> 8);
  dclcd_cmd.buf[6] = (uint8_t)cid;
  
  if(show0hide1 == 0){
    dclcd_cmd.buf[7] = 0x01u;
  }else{
    dclcd_cmd.buf[7] = 0x00u;
  }
  
  dclcd_cmd.buf[8] = 0xFFu;
  dclcd_cmd.buf[9] = 0xFCu;
  dclcd_cmd.buf[10] = 0xFFu;
  dclcd_cmd.buf[11] = 0xFFu;
  
  dclcd_cmd.cnt = 12;
  
  dclcd_send_interface(dclcd_cmd);
}

void dc_display_title(uint16_t ssid, const char *ts1, const char *ts2, const char *ts3, const char *ts4)
{
  volatile uint16_t pos;
  uint16_t len1, len2, len3, len4;
  
  len1 = strlen(ts1);
  len2 = strlen(ts2);
  len3 = strlen(ts3);
  len4 = strlen(ts4);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = (uint8_t)(ssid >> 8);
  dclcd_cmd.buf[4] = (uint8_t)ssid;
  
  pos = 5;
  
  if((pos+len1+4+4) <= DCLCD_FRAME_MAXLEN)
  {
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 8;  /* 固定位置 */
    dclcd_cmd.buf[pos++] = (uint8_t)(len1 >> 8);
    dclcd_cmd.buf[pos++] = (uint8_t)len1;
    memcpy((dclcd_cmd.buf+pos), ts1, len1);
    pos += len1;
  }
  
  if((pos+len2+4+4) <= DCLCD_FRAME_MAXLEN)
  {
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 10;  /* 固定位置 */
    dclcd_cmd.buf[pos++] = (uint8_t)(len2 >> 8);
    dclcd_cmd.buf[pos++] = (uint8_t)len2;
    memcpy((dclcd_cmd.buf+pos), ts2, len2);
    pos += len2;
  }
  
  if((pos+len3+4+4) <= DCLCD_FRAME_MAXLEN)
  {
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 12;  /* 固定位置 */
    dclcd_cmd.buf[pos++] = (uint8_t)(len3 >> 8);
    dclcd_cmd.buf[pos++] = (uint8_t)len3;
    memcpy((dclcd_cmd.buf+pos), ts3, len3);
    pos += len3;
  }
  
  if((pos+len4+4+4) <= DCLCD_FRAME_MAXLEN)
  {
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 14;  /* 固定位置 */
    dclcd_cmd.buf[pos++] = (uint8_t)(len4 >> 8);
    dclcd_cmd.buf[pos++] = (uint8_t)len4;
    memcpy((dclcd_cmd.buf+pos), ts4, len4);
    pos += len4;
  }
  
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  if(pos > 9)
  {
    dclcd_cmd.cnt = pos;
    dclcd_send_interface(dclcd_cmd);
  }
}

uint8_t dc_display_parainput(uint8_t page, uint8_t focus, const Sto_MaintainTableStru *mttb, const Sto_MaintainStru **pmt)
{
  uint16_t lnm_tp;
  volatile uint16_t pos;

  pos = 5;
  
  if(pmt == NULL)
  {
    return 1;
  }
  
  *pmt = sto_find_mt_with_uipos(page, focus, mttb);
  if(*pmt == NULL)
  {
    return 2;
  }

  if((*pmt)->fixstr == NULL)
  {
    return 3;
  }

  /* 名称显示 */
  if((*pmt)->fixstr->name2 == NULL){
    return 4;
  }else{
    lnm_tp = strlen((*pmt)->fixstr->name2);
    if((lnm_tp == 0)||((pos+4+lnm_tp+4) >= DCLCD_FRAME_MAXLEN)){
      return 5;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 7;  /* 名称控件固定7 */
      dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
      dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
      memcpy((dclcd_cmd.buf+pos), (*pmt)->fixstr->name2, lnm_tp);
      pos += lnm_tp;
    }
  }

  /* 单位显示 有错误填充 */
  if((*pmt)->fixstr->unit != NULL){
    lnm_tp = strlen((*pmt)->fixstr->unit);
    if((lnm_tp > 0) && ((pos+4+lnm_tp+4) < DCLCD_FRAME_MAXLEN)){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11;  /* 单位控件固定11 */
      dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
      dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
      memcpy((dclcd_cmd.buf+pos), (*pmt)->fixstr->unit, lnm_tp);
      pos += lnm_tp;
    }else{
      if((pos+5+4) < DCLCD_FRAME_MAXLEN){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 11;  /* 单位控件固定11 */
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
    }
  }else{
    if((pos+5+4) < DCLCD_FRAME_MAXLEN){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11;  /* 单位控件固定11 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }
  
  /* 描述显示 有错误填充 */
  if((*pmt)->fixstr->brief != NULL){
    lnm_tp = strlen((*pmt)->fixstr->brief);
    if((lnm_tp > 0) && ((pos+4+lnm_tp+4) < DCLCD_FRAME_MAXLEN)){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 12;  /* 描述控件固定11 */
      dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
      dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
      memcpy((dclcd_cmd.buf+pos), (*pmt)->fixstr->brief, lnm_tp);
      pos += lnm_tp;
    }else{
      if((pos+5+4) < DCLCD_FRAME_MAXLEN){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 12;  /* 描述控件固定11 */
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
    }
  }else{
    if((pos+5+4) < DCLCD_FRAME_MAXLEN){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 12;  /* 描述控件固定11 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }
  
  if((*pmt)->dynstr != NULL)
  {
    /* 最小值显示 */
    if((pos+4+1+4) < DCLCD_FRAME_MAXLEN){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 8;
      lnm_tp = (*pmt)->dynstr((*pmt), STO_MTDYNSTR_OUTPUT_MINVA, (char *)(dclcd_cmd.buf+pos+2), (DCLCD_FRAME_MAXLEN-pos-2-4));
      if(lnm_tp > 0){
        dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
        pos += lnm_tp;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
    }

    /* 最大值显示 */
    if((pos+4+1+4) < DCLCD_FRAME_MAXLEN){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 9;
      lnm_tp = (*pmt)->dynstr((*pmt), STO_MTDYNSTR_OUTPUT_MAXVA, (char *)(dclcd_cmd.buf+pos+2), (DCLCD_FRAME_MAXLEN-pos-2-4));
      if(lnm_tp > 0){
        dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
        pos += lnm_tp;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
    }
  }
  else
  {
    if((pos+5+5+4) < DCLCD_FRAME_MAXLEN)
    {
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 8;  /* 描述控件固定11 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 9;  /* 描述控件固定11 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }

  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;
  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x04u;  /* ssid固定为4 */
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  
  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
  
  return 0;
}

void dc_display_parainput_err(uint8_t err)
{
  dc_comp_showhide(4, 13, 0);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x10u;
  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x04u;  /* ssid固定为4 */
  dclcd_cmd.buf[5] = 0x00u;
  dclcd_cmd.buf[6] = 13u;

  dclcd_cmd.buf[7] = gui_asc_parainputerr[0];
  dclcd_cmd.buf[8] = gui_asc_parainputerr[1];
  dclcd_cmd.buf[9] = gui_asc_parainputerr[2];
  dclcd_cmd.buf[10] = gui_asc_parainputerr[3];
  dclcd_cmd.buf[11] = gui_asc_parainputerr[4];
  dclcd_cmd.buf[12] = gui_asc_parainputerr[5];
  dclcd_cmd.buf[13] = gui_asc_parainputerr[6];
  dclcd_cmd.buf[14] = gui_asc_parainputerr[7];
  dclcd_cmd.buf[15] = gui_asc_parainputerr[8];
  dclcd_cmd.buf[16] = err+'0';

  dclcd_cmd.buf[17] = 0xFFu;
  dclcd_cmd.buf[18] = 0xFCu;
  dclcd_cmd.buf[19] = 0xFFu;
  dclcd_cmd.buf[20] = 0xFFu;
  
  dclcd_cmd.cnt = 21;
  dclcd_send_interface(dclcd_cmd);
}

void dc_display_paralist(uint8_t page, uint8_t firstf, const Sto_MaintainTableStru *mttb)
{
  uint8_t  i, loc;
  uint16_t lnm_tp;
  uint16_t cid;
  volatile uint16_t pos;
  const Sto_MaintainStru *pmt = NULL;

  pos = 5;

  for(i=0; i<4; (i++, firstf++))
  {
    loc = (firstf%4)*4;
    pmt = sto_find_mt_with_uipos(page, firstf, mttb);
    if(pmt == NULL){
      if((pos+15+4) < DCLCD_FRAME_MAXLEN){
        cid = loc+8;
        dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)cid;
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';

        cid = loc+9;
        dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)cid;
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';

        cid = loc+10;
        dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)cid;
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      continue;
    }

    if(pmt->fixstr != NULL)
    {
      cid = loc+8;
      if(pmt->fixstr->name1 != NULL){
        lnm_tp = strlen(pmt->fixstr->name1);
        if((lnm_tp > 0) && ((pos+4+lnm_tp+4) < DCLCD_FRAME_MAXLEN)){
          dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
          dclcd_cmd.buf[pos++] = (uint8_t)cid;
          dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
          dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
          memcpy((dclcd_cmd.buf+pos), pmt->fixstr->name1, lnm_tp);
          pos += lnm_tp;
        }else{
          if((pos+5+4) < DCLCD_FRAME_MAXLEN){
            dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
            dclcd_cmd.buf[pos++] = (uint8_t)cid;
            dclcd_cmd.buf[pos++] = 0;
            dclcd_cmd.buf[pos++] = 1;
            dclcd_cmd.buf[pos++] = ' ';
          }
        }
      }else{
        if((pos+5+4) < DCLCD_FRAME_MAXLEN){
          dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
          dclcd_cmd.buf[pos++] = (uint8_t)cid;
          dclcd_cmd.buf[pos++] = 0;
          dclcd_cmd.buf[pos++] = 1;
          dclcd_cmd.buf[pos++] = ' ';
        }
      }

      cid = loc+10;
      if(pmt->fixstr->unit != NULL){
        lnm_tp = strlen(pmt->fixstr->unit);
        if((lnm_tp > 0) && ((pos+4+lnm_tp+4) < DCLCD_FRAME_MAXLEN)){
          dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
          dclcd_cmd.buf[pos++] = (uint8_t)cid;
          dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
          dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
          memcpy((dclcd_cmd.buf+pos), pmt->fixstr->unit, lnm_tp);
          pos += lnm_tp;
        }else{
          if((pos+5+4) < DCLCD_FRAME_MAXLEN){
            dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
            dclcd_cmd.buf[pos++] = (uint8_t)cid;
            dclcd_cmd.buf[pos++] = 0;
            dclcd_cmd.buf[pos++] = 1;
            dclcd_cmd.buf[pos++] = ' ';
          }
        }
      }else{
        if((pos+5+4) < DCLCD_FRAME_MAXLEN){
          dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
          dclcd_cmd.buf[pos++] = (uint8_t)cid;
          dclcd_cmd.buf[pos++] = 0;
          dclcd_cmd.buf[pos++] = 1;
          dclcd_cmd.buf[pos++] = ' ';
        }
      }
    }
    else  /* pmt->fixstr == NULL */
    {
      if((pos+10+4) < DCLCD_FRAME_MAXLEN){
        cid = loc+8;
        dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)cid;
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';

        cid = loc+10;
        dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)cid;
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
    }

    /* value */
    cid = loc+9;
    if(pmt->dynstr != NULL)
    {
      if((pos+5+4) < DCLCD_FRAME_MAXLEN){
        dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)cid;
        lnm_tp = pmt->dynstr(pmt, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), (DCLCD_FRAME_MAXLEN-pos-2-4));
        if(lnm_tp > 0){
          dclcd_cmd.buf[pos++] = (uint8_t)(lnm_tp >> 8);
          dclcd_cmd.buf[pos++] = (uint8_t)lnm_tp;
          pos += lnm_tp;
        }else{
          dclcd_cmd.buf[pos++] = 0;
          dclcd_cmd.buf[pos++] = 1;
          dclcd_cmd.buf[pos++] = ' ';
        }
      }
    }
    else
    {
      if((pos+5+4) < DCLCD_FRAME_MAXLEN){
        dclcd_cmd.buf[pos++] = (uint8_t)(cid >> 8);
        dclcd_cmd.buf[pos++] = (uint8_t)cid;
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
    }
  } /* for firstf++ */

  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x03u;  /* ssid固定为3 */

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  if(pos > 9)
  {
    dclcd_cmd.cnt = pos;
    dclcd_send_interface(dclcd_cmd);
  }
}

void dc_load_calmessage(uint8_t nowpage, uint8_t nowfocus)
{
  uint16_t len;
  uint16_t pos;
  const char *pstr = NULL;

  dc_cmd_change_screen(9);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 9u;  /* ssid固定为10 */

  pos = 5;

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8; /* cid固定8 整圈方式 */

  switch(nowpage)
  {
    case 1:
      pstr = gui_asc_msg01;
      break;

    case 2:
      pstr = gui_asc_msg02;
      break;

    case 3:
      pstr = gui_asc_msg03;
      break;

    case 4:
      pstr = gui_asc_msg04;
      break;

    default:
      pstr = gui_asc_msg00;
      break;
  }

  if(pstr == NULL)
  {
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  else
  {
    len = strlen(pstr);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), pstr, len);
    pos += len;
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_load_calzeroready(uint8_t nowpage, uint8_t nowfocus)
{
  uint16_t len;
  uint16_t pos;
  
  dc_cmd_change_screen(10);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 10u;  /* ssid固定为10 */
  
  pos = 5;

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7; /* cid固定7 整圈方式 */
  len = sto_dynstr_fpointer(len_circle_mode)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9; /* cid固定9 手动调零幅度 */
  len = sto_dynstr_fpointer(manu_zero_range)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10; /* cid固定10 零点内码上限 */
  len = sto_dynstr_fpointer(zero_code_uplimit)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  if(gv.hr.meas_pa.len_circle_mode != MEAS_LEN_CIRCLE_FIXTIME)
  {
    /* 定长模式 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 11; /* cid固定11 零点内码上限 */
    len = strlen(gui_asc_calzeroready_pdzc);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_calzeroready_pdzc, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 12; /* cid固定11 零点内码上限 */
    len = strlen(sto_fixstr_pointer(belt_length_mm).unit);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(belt_length_mm).unit, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 8; /* cid固定11 零点内码上限 */
    len = sto_dynstr_fpointer(belt_length_mm)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }
  else
  {
    /* 定时模式 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 11; /* cid固定11 零点内码上限 */
    len = strlen(gui_asc_calzeroready_pdzq);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_calzeroready_pdzq, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 12; /* cid固定11 零点内码上限 */
    len = strlen(sto_fixstr_pointer(belt_period_0d01s).unit);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(belt_period_0d01s).unit, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 8; /* cid固定11 零点内码上限 */
    len = sto_dynstr_fpointer(belt_period_0d01s)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_load_calzeroend(uint8_t nowpage, uint8_t nowfocus)
{
  uint16_t len;
  uint16_t pos;
  
  dc_cmd_change_screen(8);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 8u;  /* ssid固定为10 */
  
  pos = 5;

/***** 新零点值 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ca.calmzero_zero_adjust1);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_load_calgmend(uint8_t nowpage, uint8_t nowfocus)
{
  uint16_t len;
  uint16_t pos;
  
  dc_cmd_change_screen(13);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 13u;  /* ssid固定为10 */
  
  pos = 5;

/***** 累积量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%0.4f", gv.ir.meas_ca.calgm_actual_total_0d1g/10000000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 理论量标题显示 *****/
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  len = strlen(gui_asc_clagmlll);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_clagmlll, len);
  pos += len;

/***** 理论量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%0.4f", gv.ir.meas_ca.calgm_theory_total_0d1g/10000000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = 't';

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_load_calswend(uint8_t nowpage, uint8_t nowfocus)
{
  uint16_t len;
  uint16_t pos;
  
  dc_cmd_change_screen(16);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 16u;
  
  pos = 5;

/***** 累积量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%0.4f", gv.ir.meas_ca.calsw_actual_total_0d1g/10000000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 理论量标题显示 *****/
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  len = strlen(gui_asc_claswsjl);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_claswsjl, len);
  pos += len;

/***** 理论量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%0.3f", gv.hr.meas_pa.cal_shiwu_weight_kg/1000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = 't';

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_load_calgmready(uint8_t nowpage, uint8_t nowfocus)
{
  uint16_t len;
  uint16_t pos;
  
  dc_cmd_change_screen(11);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 11u;  /* ssid固定为10 */
  
  pos = 5;
  
  /* cid固定7 整圈方式 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7; 
  len = sto_dynstr_fpointer(len_circle_mode)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  /* cid固定8 12 皮带周期 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8; 
  len = sto_dynstr_fpointer(belt_period_0d01s)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  len = strlen(sto_fixstr_pointer(belt_period_0d01s).unit);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(belt_period_0d01s).unit, len);
  pos += len;

  /* cid固定9 13 皮带周长 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  len = sto_dynstr_fpointer(belt_length_mm)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 13;
  len = strlen(sto_fixstr_pointer(belt_length_mm).unit);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(belt_length_mm).unit, len);
  pos += len;
  
  /* cid固定10 14 称量长度 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  len = sto_dynstr_fpointer(effect_length_mm)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 14;
  len = strlen(sto_fixstr_pointer(effect_length_mm).unit);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(effect_length_mm).unit, len);
  pos += len;

  /* cid固定11 15 砝码重量 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  len = sto_dynstr_fpointer(cal_fama_weight_0d1g)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 15;
  len = strlen(sto_fixstr_pointer(cal_fama_weight_0d1g).unit);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(cal_fama_weight_0d1g).unit, len);
  pos += len;

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_load_calswready(uint8_t nowpage, uint8_t nowfocus)
{
  uint16_t len;
  uint16_t pos;
  
  dc_cmd_change_screen(14);
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 14u;  /* ssid固定为10 */
  
  pos = 5;

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7; /* cid固定7 整圈方式 */
  len = sto_dynstr_fpointer(len_circle_mode)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  
  /* cid固定9 13 物料重量 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  len = sto_dynstr_fpointer(cal_shiwu_weight_kg)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 13;
  len = strlen(sto_fixstr_pointer(cal_shiwu_weight_kg).unit);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(cal_shiwu_weight_kg).unit, len);
  pos += len;

  if(gv.hr.meas_pa.len_circle_mode != MEAS_LEN_CIRCLE_FIXTIME)
  {
    /* 定长模式 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 11; /* cid固定11 零点内码上限 */
    len = strlen(gui_asc_calzeroready_pdzc);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_calzeroready_pdzc, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 12; /* cid固定11 零点内码上限 */
    len = strlen(sto_fixstr_pointer(belt_length_mm).unit);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(belt_length_mm).unit, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 8; /* cid固定11 零点内码上限 */
    len = sto_dynstr_fpointer(belt_length_mm)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }
  else
  {
    /* 定时模式 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 11; /* cid固定11 零点内码上限 */
    len = strlen(gui_asc_calzeroready_pdzq);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_calzeroready_pdzq, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 12; /* cid固定11 零点内码上限 */
    len = strlen(sto_fixstr_pointer(belt_period_0d01s).unit);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_pointer(belt_period_0d01s).unit, len);
    pos += len;
    
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 8; /* cid固定11 零点内码上限 */
    len = sto_dynstr_fpointer(belt_period_0d01s)(NULL, STO_MTDYNSTR_OUTPUT_VALUE, (char *)(dclcd_cmd.buf+pos+2), 16);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_update_main(uint8_t key)
{
  uint16_t len;
  uint16_t pos;
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x00u;  /* ssid固定为0 */
  
  pos = 5;

  switch(gv.hr.meas_pa.main_display_pos2)
  {
    case 1:  /* 单位长度载荷 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 7;
      len = strlen(gui_asc_zaihe);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_zaihe, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 9;
      len = strlen(gui_asc_general_unit_kgm);
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_general_unit_kgm, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 8;
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%.3f", gv.ir.meas_ca.belt_load_gm/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;

    case 2:  /* 皮带速度 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 7;
      len = strlen(gui_asc_sudu);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_sudu, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 9;
      len = strlen(gui_asc_general_unit_ms);
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_general_unit_ms, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 8;
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%.3f", gv.ir.meas_ca.belt_speed_mms/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;

    case 0:  /* 流量 */
    default:
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 7;
      len = strlen(gui_asc_liuliang);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_liuliang, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 9;
      len = strlen(gui_asc_general_unit_th);
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_general_unit_th, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 8;
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%.3f", gv.ir.meas_ca.flowrate_kgh/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;
  }

  switch(gv.hr.meas_pa.main_display_pos1)
  {
    default:
    case 0:  /* 班累计 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 10;
      len = strlen(gui_asc_classacc);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_classacc, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11; /* TODO: 这里需要有当前班切换 */
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", meas_get_current_class_prod(&gv)/10000000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;

    case 1:  /* 日累计 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 10;
      len = strlen(gui_asc_dayacc);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_dayacc, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11; /* TODO: 这里需要有当前班切换 */
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.day_acc_kg/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;

    case 2:  /* 月累计 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 10;
      len = strlen(gui_asc_monthacc);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_monthacc, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11; /* TODO: 这里需要有当前班切换 */
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.month_acc_kg/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;

    case 3:  /* 年累计 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 10;
      len = strlen(gui_asc_yearacc);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_yearacc, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11;
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.year_acc_kg/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;
      
    case 4:  /* 时累计 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 10;
      len = strlen(gui_asc_houracc);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_houracc, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11;
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.hour_acc_kg/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;
      
    case 5:  /* 间隔产量 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 10;
      len = strlen(gui_asc_intvacc);  /* 名称 */
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_intvacc, len);
      pos += len;

      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 11;
      len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.interval_acc_kg/1000.0);
      if(len > 0){
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = (uint8_t)len;
        pos += len;
      }else{
        dclcd_cmd.buf[pos++] = 0;
        dclcd_cmd.buf[pos++] = 1;
        dclcd_cmd.buf[pos++] = ' ';
      }
      break;
  }
  
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.total_acc_kg/1000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_update_calzerorunning(uint8_t key)
{
  uint16_t len;
  uint16_t pos;
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x07u;  /* ssid固定为7 */
  
  pos = 5;

/***** 重量内码 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ad.wad_unified);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 上圈平均重量内码 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ca.calmzero_zero_adjust1);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 当前圈数 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 6, "%u", gv.ir.meas_ca.calmzero_elapsed_belt_cnt);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 当前零点内码 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.hr.meas_pa.zero_code_ave);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  if(gv.hr.meas_pa.len_circle_mode != MEAS_LEN_CIRCLE_FIXTIME)
  {
/***** 剩余长度 *****/
    /* 数值 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 9;
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%u", gv.ir.meas_ca.calmzero_belt_remainder_mm);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
    
    /* 单位 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 10;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 2;
    dclcd_cmd.buf[pos++] = 'm';
    dclcd_cmd.buf[pos++] = 'm';
  }
  else
  {
/***** 剩余时间 *****/
    /* 数值 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 9;
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%u.%02u", gv.ir.meas_ca.calmzero_belt_remainder_0d01s/100, \
                                                                 gv.ir.meas_ca.calmzero_belt_remainder_0d01s%100);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
    
    /* 单位 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 10;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = 's';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_update_calgmrunning(uint8_t key)
{
  uint16_t len;
  uint16_t pos;
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 12u;  /* ssid固定为12 */
  
  pos = 5;

/***** 累积量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%.4f", gv.ir.meas_ca.calgm_actual_total_0d1g/10000000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 当前流量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%.3f", gv.ir.meas_ca.flowrate_kgh/1000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  if(gv.hr.meas_pa.len_circle_mode != MEAS_LEN_CIRCLE_FIXTIME)
  {
/***** 剩余长度 *****/
    /* 数值 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 9;
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%u", gv.ir.meas_ca.calgm_belt_remainder_mm);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
    
    /* 单位 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 10;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 2;
    dclcd_cmd.buf[pos++] = 'm';
    dclcd_cmd.buf[pos++] = 'm';
  }
  else
  {
/***** 剩余时间 *****/
    /* 数值 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 9;
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%u.%02u", gv.ir.meas_ca.calgm_belt_remainder_0d01s/100, \
                                                                 gv.ir.meas_ca.calgm_belt_remainder_0d01s%100);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }

    /* 单位 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 10;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = 's';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_update_calswrunning(uint8_t key)
{
  uint16_t len;
  uint16_t pos;
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 15u;  /* ssid固定为12 */
  
  pos = 5;

/***** 累积量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%.4f", gv.ir.meas_ca.calsw_actual_total_0d1g/10000000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 当前流量 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%.3f", gv.ir.meas_ca.flowrate_kgh/1000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 皮带运行圈数 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%u", gv.ir.meas_ca.calsw_elapsed_belt_cnt);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  if(gv.hr.meas_pa.len_circle_mode != MEAS_LEN_CIRCLE_FIXTIME)
  {
/***** 剩余长度 *****/
    /* 数值 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 9;
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%u", gv.ir.meas_ca.calsw_belt_remainder_mm);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
    
    /* 单位 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 12;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 2;
    dclcd_cmd.buf[pos++] = 'm';
    dclcd_cmd.buf[pos++] = 'm';
  }
  else
  {
/***** 剩余时间 *****/
    /* 数值 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 9;
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%u.%02u", gv.ir.meas_ca.calsw_belt_remainder_0d01s/100, \
                                                                 gv.ir.meas_ca.calsw_belt_remainder_0d01s%100);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }

    /* 单位 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 12;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = 's';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_display_state_pg1(void)
{
  uint16_t len;
  uint16_t pos;
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x01u;  /* ssid固定为1 */
  
  pos = 5;

/*****  重量内码 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = strlen(gui_asc_wad);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_wad, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ad.wad_unified);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  零点内码 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  len = strlen(gui_asc_zeroad);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_zeroad, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.hr.meas_pa.zero_code_ave);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  速度内码 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 13;
  len = strlen(gui_asc_sad);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_sad, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 14;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.ir.meas_ad.sad_hz);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 15;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 2;
  dclcd_cmd.buf[pos++] = 'H';
  dclcd_cmd.buf[pos++] = 'z';

/***** 称量系数 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 16;
  len = strlen(sto_fixstr_namestr(weight_factor_base));
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), sto_fixstr_namestr(weight_factor_base), len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 17;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.hr.meas_pa.weight_factor_base);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 18;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';
  
/***** 页码显示 *****/
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 19;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 12, "(1/4)");
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_display_state_pg2(void)
{
  uint16_t len;
  uint16_t pos;
  
  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;
  
  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x01u;  /* ssid固定为1 */
  
  pos = 5;

/***** 流量 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = strlen(gui_asc_liuliang);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_liuliang, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.flowrate_kgh/1000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 3;
  dclcd_cmd.buf[pos++] = 't';
  dclcd_cmd.buf[pos++] = '/';
  dclcd_cmd.buf[pos++] = 'h';

/*****  速度 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  len = strlen(gui_asc_sudu);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_sudu, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.belt_speed_mms/1000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 3;
  dclcd_cmd.buf[pos++] = 'm';
  dclcd_cmd.buf[pos++] = '/';
  dclcd_cmd.buf[pos++] = 's';

/*****  载荷 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 13;
  len = strlen(gui_asc_zaihe);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_zaihe, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 14;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.belt_load_gm/1000.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 15;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 4;
  dclcd_cmd.buf[pos++] = 'k';
  dclcd_cmd.buf[pos++] = 'g';
  dclcd_cmd.buf[pos++] = '/';
  dclcd_cmd.buf[pos++] = 'm';

/*****  cpu运行时间 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 16;
  len = strlen(gui_asc_cpuruntime);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_cpuruntime, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 17;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%.3f", gv.ir.meas_ca.cpu_runtime/3600.0);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 18;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = 'h';

/***** 页码显示 *****/
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 19;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 12, "(2/4)");
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_display_state_pg3(void)
{
  uint16_t len;
  uint16_t pos;

  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;

  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x01u;  /* ssid固定为1 */

  pos = 5;

/*****  称重传感器1内码 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = strlen(gui_asc_wt1sensorcode);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_wt1sensorcode, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ad.wad_divided[0]);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  称重传感器2内码 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  len = strlen(gui_asc_wt2sensorcode);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_wt2sensorcode, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ad.wad_divided[1]);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  称重传感器3内码 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 13;
  len = strlen(gui_asc_wt3sensorcode);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_wt3sensorcode, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 14;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ad.wad_divided[2]);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 15;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  称重传感器4内码 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 16;
  len = strlen(gui_asc_wt4sensorcode);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_wt4sensorcode, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 17;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 8, "%d", gv.ir.meas_ad.wad_divided[3]);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 18;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/***** 页码显示 *****/
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 19;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 12, "(3/4)");
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

void dc_display_state_pg4(void)
{
  uint16_t len;
  uint16_t pos;

  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;

  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 0x01u;  /* ssid固定为1 */

  pos = 5;

/*****  序列号 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = strlen(gui_asc_sn);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_sn, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 8;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 12, "%s", (const char *)gv.ir.meas_ca.str_sn);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  固件版本 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  len = strlen(gui_asc_sv);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_sv, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 12, "%s", (const char *)gv.ir.meas_ca.str_sv);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  PCB版本 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 13;
  len = strlen(gui_asc_pv);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_pv, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 14;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 12, "%s", (const char *)gv.ir.meas_ca.str_pv);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 15;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/*****  UI版本 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 16;
  len = strlen(gui_asc_uv);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_uv, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 17;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 16, "%s", (const char *)gv.ir.meas_ca.str_uv);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }
  /* 单位 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 18;
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 1;
  dclcd_cmd.buf[pos++] = ' ';

/***** 页码显示 *****/
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 19;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 12, "(4/4)");
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}

/* idx 0~3:称重  4:速度 */
void dc_update_sensorinfo(uint8_t idx)
{
  const char *p = NULL;
  const char *p2 = NULL;
  uint8_t addr;
  uint16_t len;
  uint16_t pos;

  switch(idx)
  {
    case 0:
      addr = gv.hr.meas_pa.wt1_sensor_addr;
      p = gui_asc_wtsensor01;
      p2 = gui_asc_wtrange;
      break;

    case 1:
      addr = gv.hr.meas_pa.wt2_sensor_addr;
      p = gui_asc_wtsensor02;
      p2 = gui_asc_wtrange;
      break;

    case 2:
      addr = gv.hr.meas_pa.wt3_sensor_addr;
      p = gui_asc_wtsensor03;
      p2 = gui_asc_wtrange;
      break;

    case 3:
      addr = gv.hr.meas_pa.wt4_sensor_addr;
      p = gui_asc_wtsensor04;
      p2 = gui_asc_wtrange;
      break;

    case 4:
      addr = gv.hr.meas_pa.spd_sensor_addr;
      p = gui_asc_spdsensor;
      p2 = gui_asc_spdgears;
      break;

    default:
      return;
  }

  dclcd_cmd.buf[0] = DCLCD_FRAME_HEADER;

  dclcd_cmd.buf[1] = 0xB1u;
  dclcd_cmd.buf[2] = 0x12u;

  dclcd_cmd.buf[3] = 0x00u;
  dclcd_cmd.buf[4] = 17u;

  pos = 5;
/***** 名称 *****/
  /* 标题 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 16;
  len = snprintf((char *)(dclcd_cmd.buf+pos+2), 24, "%s(%s%u)", p, gui_asc_address, addr);
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 出厂编号 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 9;
  if(idx < 4){
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 20, "%llu", gv.ir.meas_ca.wt_sensor_info[idx].sn);
  }else{
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 20, "%llu", gv.ir.meas_ca.spd_sensor_info.sn);
  }
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 内码值 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 10;
  if(idx < 4){
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.ir.meas_ca.wt_sensor_info[idx].srccode);
  }else{
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.ir.meas_ca.spd_sensor_info.srccode);
  }
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 状态 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 11;
  if(idx < 4){
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.ir.meas_ca.wt_sensor_info[idx].state);
  }else{
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.ir.meas_ca.spd_sensor_info.state);
  }
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 程序版本 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 12;
  if(idx < 4){
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.ir.meas_ca.wt_sensor_info[idx].sv);
  }else{
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%u", gv.ir.meas_ca.spd_sensor_info.sv);
  }
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/***** 温度 *****/
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 13;
  if(idx < 4){
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%.1f%s", (float)gv.ir.meas_ca.wt_sensor_info[idx].temperature/10.0, gui_asc_temper);
  }else{
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%.1f%s", (float)gv.ir.meas_ca.spd_sensor_info.temperature/10.0, gui_asc_temper);
  }
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

/*****  UI版本 *****/
  /* 名称 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 7;
  len = strlen(p2);
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = (uint8_t)len;
  memcpy((char *)(dclcd_cmd.buf+pos), p2, len);
  pos += len;
  /* 数值 */
  dclcd_cmd.buf[pos++] = 0;
  dclcd_cmd.buf[pos++] = 14;
  if(idx < 4){
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 10, "%ug", gv.ir.meas_ca.wt_sensor_info[idx].range);
  }else{
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 6, "%u", gv.ir.meas_ca.spd_sensor_info.gears);
  }
  if(len > 0){
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    pos += len;
  }else{
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  if(idx == 4)
  {
    /* 名称 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 8;
    len = strlen(gui_asc_spdiameter);
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = (uint8_t)len;
    memcpy((char *)(dclcd_cmd.buf+pos), gui_asc_spdiameter, len);
    pos += len;
    /* 数值 */
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 15;
    len = snprintf((char *)(dclcd_cmd.buf+pos+2), 6, "%.1fmm", (float)gv.ir.meas_ca.spd_sensor_info.diameter/10.0);
    if(len > 0){
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = (uint8_t)len;
      pos += len;
    }else{
      dclcd_cmd.buf[pos++] = 0;
      dclcd_cmd.buf[pos++] = 1;
      dclcd_cmd.buf[pos++] = ' ';
    }
  }
  else
  {
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 8;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';

    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 15;
    dclcd_cmd.buf[pos++] = 0;
    dclcd_cmd.buf[pos++] = 1;
    dclcd_cmd.buf[pos++] = ' ';
  }

  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFCu;
  dclcd_cmd.buf[pos++] = 0xFFu;
  dclcd_cmd.buf[pos++] = 0xFFu;

  dclcd_cmd.cnt = pos;
  dclcd_send_interface(dclcd_cmd);
}